# 定时的服务
import celery
import time

backend = "redis://127.0.0.1:6379/1" # 结果存储
broker = 'redis://127.0.0.1:6379/2' # 消息中间件

cel = celery.Celery('test', backend=backend, broker=broker)

@cel.task
def send_email(name):
    print("向%s发送邮箱。。。" % name)
    time.sleep(5)
    print("向%s发送邮箱完成..." % name)
    return "ok"

@cel.task
def send_msg(name):
    print("向%s发送短信。。。" % name)
    time.sleep(5)
    print("向%s发送短信完成..." % name)
    return "ok"